﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using HigLabo.Net.Extensions;
using Newtonsoft.Json.Linq;

namespace HigLabo.Net.Twitter
{
    /// <summary>
    /// 
    /// </summary>
    public class Trends : ResponseObject
    {
        /// <summary>
        /// 
        /// </summary>
        public DateTimeOffset CreatedAt { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public DateTimeOffset AsOf { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public LocationCollection Locations { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public TrendCollection TrendList { set; get; }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonText"></param>
        public Trends(String jsonText)
        {
            this.SetProperty(jsonText);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonText"></param>
        public override void SetProperty(string jsonText)
        {            
            var d = this.SetData(jsonText);

            this.CreatedAt = d.ToDateTimeOffset("created_at") ?? this.CreatedAt;
            this.AsOf = d.ToDateTimeOffset("as_of") ?? this.AsOf;
            this.Locations = new LocationCollection(d.ToString("locations"));
            this.TrendList = new TrendCollection(d.ToString("trends"));
        }
    }
}
